package com.kb.design.mapper.postgreSQL;



import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kb.design.dto.DesignRequirementDTO;
import com.kb.design.entity.DesignBonusDistribution;
import com.kb.design.entity.DesignResponsiblePerson;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * (CustomUser)表数据库访问层
 *
 * @author makejava
 * @since 2023-08-22 10:56:59
 */
@Mapper
public interface DesignResponsiblePersonMapper extends BaseMapper<DesignResponsiblePerson> {

    Page<DesignRequirementDTO> queryDesignPage(Page<DesignRequirementDTO> page , DesignRequirementDTO designRequirementDTO);

    @Select("SELECT r.* FROM design_project p LEFT JOIN design_responsible_person r ON p.id = r.project_id WHERE r.del = '0' and p.id = #{id}")
    public List<DesignResponsiblePerson> searchDetailsInfo(Long id);

    @Select({
        "<script>",
        "SELECT r.* FROM design_responsible_person r",
        "LEFT JOIN design_project p ON r.project_id = p.id",
        "WHERE r.person_type = '1'",
        "AND node_status = '10'",
        "AND p.order_id = #{orderId}",
        "LIMIT 1",
        "</script>"
    })
    DesignResponsiblePerson queryByOrderId(@Param("orderId") Long orderId);


    @Update("UPDATE design_responsible_person SET del = #{del} WHERE project_id = #{projectId} and node_status = #{status}")
    void updateByStatus(@Param("projectId") Long projectId,@Param("status") String status,@Param("del") String del);

}

